#pragma once
#include <string>
#include <mutex>
#include <queue>
#include "../utils/ThreadPool/TaskExecutor.h"

class LogManager
{
public:
    static LogManager &getInstance();
    void init(const std::string &logDir = "../logs/");
    void log(const std::string &type, const std::string &message);
    void flush();

private:
    LogManager();
    ~LogManager();
    void writeToFile(const std::string &fullMsg);
    void rotate();

    std::string logDir;
    std::string logFileName = "log.txt";
    std::mutex mutex;
    std::unique_ptr<TaskExecutor> executor;
    size_t maxFileSize = 10 * 1024 * 1024;
    int maxBackup = 5;
};
